const {
  unDefined,
  nullValue,
  emailver,
  passwordver,
} = require("@/utils/valiData");
const result = require("@/utils/handle");
// 分析游记关键词
const ArticleKeyword = (text) => {
  unDefined([text]);
};

// 发布游记：图片类型
const ArticlePublish = (
  title,
  content,
  image,
  address,
  province,
  city,
  tag
) => {
  unDefined([title, content, image, address, province, city, tag]);
  nullValue([
    { value: title, tips: "请输入游记标题" },
    { value: content, tips: "请输入游记内容" },
    { value: image, tips: "请上传游记图片" },
    { value: address, tips: "请选择城市" },
    { value: province, tips: "请选择城市" },
    { value: city, tips: "请选择城市" },
    { value: tag, tips: "请选择游记标签" },
  ]);
  if (!Array.isArray(image)) {
    throw new result("image字段应为数组类型", 422);
  }
  if (image.length === 0) {
    throw new result("请上传游记图片", 422);
  }
  if (!Array.isArray(tag)) {
    throw new result("tag字段应为数组类型", 422);
  }
  if (tag.length === 0) {
    throw new result("请选择游记标签", 422);
  }
};

// 发布游记：视频类型
const ArticlePublishVideo = (
  title,
  content,
  address,
  province,
  city,
  tag,
  videoPoster,
  videoUrl,
  videoWidth,
  videoHeight
) => {
  unDefined([
    title,
    content,
    address,
    province,
    city,
    tag,
    videoPoster,
    videoUrl,
    videoWidth,
    videoHeight,
  ]);
  nullValue([
    { value: title, tips: "请输入游记标题" },
    { value: content, tips: "请输入游记内容" },
    { value: address, tips: "请选择城市" },
    { value: province, tips: "请选择城市" },
    { value: city, tips: "请选择城市" },
    { value: tag, tips: "请选择游记标签" },
    { value: videoPoster, tips: "请上传游记封面图" },
    { value: videoUrl, tips: "请上传游记视频" },
    { value: videoWidth, tips: "请输入视频宽度" },
    { value: videoHeight, tips: "请输入视频高度" },
  ]);
  if (!Array.isArray(tag)) {
    throw new result("tag字段应为数组类型", 422);
  }
  if (tag.length === 0) {
    throw new result("请选择游记标签", 422);
  }
};

const CompanionDetails = (_id) => {
  unDefined([_id]);
  nullValue([
    { value: _id, tips: "请输入_id" },
  ]);
}

// 用户评论游记
const Comment = (article_id, comment_content) => {
  unDefined([article_id, comment_content])
  nullValue([
      { value: article_id, tips: '缺少_id' },
      { value: comment_content, tips: '请填写评论内容' }
  ])
}

// 获取游记的评论数据
const Commentget = (article_id, page) => {
  unDefined([article_id, page])
  nullValue([
      { value: article_id, tips: '缺少_id' },
      { value: page, tips: '缺少分页值' }
  ])
}

// 关注接口
const Userconcern = (im_concerned_uid) => {
  unDefined([im_concerned_uid])
  nullValue([
      { value: im_concerned_uid, tips: '缺少作者uid' }
  ])
}
const Resreturn = (page) => {
  unDefined([page]);
  nullValue([{ value: page, tips: "请输入页码" }]);
};


module.exports = {
  ArticleKeyword,
  ArticlePublish,
  ArticlePublishVideo,
  CompanionDetails,
  Comment,
  Commentget,
  Userconcern,
  Resreturn
};
